#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QList>
#include "maplayer.h"
#include "layerconfigmanager.h"

// MapLibre相关头文件
#include <QMapLibre/QMapLibre>
#include <QMapLibreWidgets/QMapLibreWidgets>

using namespace QMapLibre;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_addLayerButton_clicked();
    void on_removeLayerButton_clicked();
    void on_layerList_itemSelectionChanged();
    void on_moveUpButton_clicked();
    void on_moveDownButton_clicked();
    void on_visibilityCheckBox_stateChanged(int arg1);
    void on_saveConfigButton_clicked();
    void on_loadConfigButton_clicked();

private:
    Ui::MainWindow *ui;
    GLWidget *m_mapWidget;
    QList<MapLayer> m_layers;
    LayerConfigManager *m_configManager;
    
    void setupMap();
    void updateLayerList();
    void updateLayerVisibility(const QString &layerId, bool visible);
    void addLayerToMap(const MapLayer &layer, int index);
    void removeLayerFromMap(QString layerId);
    void reorderLayers();
};

#endif // MAINWINDOW_H